<template>
  <div class="el-div">
    <div class="el-div el-s">
      <el-input v-model="input" placeholder="请输入内容" size="mini"></el-input>
    </div>
    <div class="el-div">
      <el-button type="primary" icon="el-icon-search" size="mini"
      >搜索
      </el-button
      >
    </div>
    <div class="el-div">
      <el-button @click="cz" size="mini">重置</el-button>
    </div>
    <div class="el-div">
      <el-button
        type="primary"
        @click="
          addDialog()
        "
        size="mini"
      >添加数据库
      </el-button
      >
      <el-dialog :title="title" :visible.sync="dialogFormVisible" width="30%">
        <el-form>
          <el-form-item label="数据库类型:" :label-width="formLabelWidth">
            <el-select v-model="dbType" placeholder="请选择" size="mini">
              <el-option
                v-for="item in dbTypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="数据库名称：" :label-width="formLabelWidth">
            <el-input
              v-model="dbConnectionName"
              autocomplete="off"
              placeholder="请输入数据库名称"
              size="mini"
            ></el-input>
          </el-form-item>
          <el-form-item label="数据库地址：" :label-width="formLabelWidth">
            <el-input
              v-model="dbConnectionUrl"
              autocomplete="off"
              placeholder="请输入数据库地址"
              size="mini"
            ></el-input>
          </el-form-item>
          <el-form-item label="数据库用户：" :label-width="formLabelWidth">
            <el-input
              v-model="dbConnectionUser"
              autocomplete="off"
              placeholder="请输入数据库用户"
              size="mini"
            ></el-input>
          </el-form-item>
          <el-form-item label="数据库密码：" :label-width="formLabelWidth">
            <el-input
              v-model="dbConnectionPassword"
              autocomplete="off"
              placeholder="请输入数据库密码"
              size="mini"
              type="password"
              show-password
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false" size="mini"
          >取 消
          </el-button
          >
          <el-button
            type="primary"
            @click="dj()"
            size="mini"
          >确 定
          </el-button
          >
        </div>
      </el-dialog>
    </div>
    <el-table :data="dbConnectionPage.data.list" border size="mini">
      <el-table-column
        type="index"
        label="序号"
        width="80"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="dbConnectionName"
        label="数据库连接名称"
        width="300"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="dbConnectionUrl"
        label="数据连接地址"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        width="300"
        align="center"
        :formatter="createTimeFormatter"
      ></el-table-column>
      <el-table-column
        prop="updateTime"
        label="更新时间"
        width="300"
        align="center"
        :formatter="updateTimeFormatter"
      ></el-table-column>
      <el-table-column label="操作" align="center" width="200">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
          >编辑
          </el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
          >删除
          </el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      layout="total,sizes,prev,pager,next,jumper"
      :page-sizes="[5, 10, 15, 20]"
      :page-size="dbConnectionPage.data.pageSize"
      :current-page="dbConnectionPage.data.pageNumber"
      :total="dbConnectionPage.data.total"
      style="float: right; margin-top: 10px; margin-bottom: 10px"
      :small="true"
    >
    </el-pagination>
  </div>
</template>

<script>
  import index from './index';

  export default index;

</script>
<style>

  @import "index.css";

</style>
